package com.example.ytyproject.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.ytyproject.config.exception.AppException;
import com.example.ytyproject.entity.ShopBoardInfo;
import com.example.ytyproject.entity.vo.R;
import com.example.ytyproject.mapper.ShopBoardInfoMapper;
import com.example.ytyproject.service.ShopBoardInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商铺餐桌管理信息表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-07-17
 */
@Service
public class ShopBoardInfoServiceImpl extends ServiceImpl<ShopBoardInfoMapper, ShopBoardInfo> implements ShopBoardInfoService {

    @Override
    public R queryAllByShopId(String shopId) {
        List<ShopBoardInfo> list = this.list(new QueryWrapper<ShopBoardInfo>().lambda().eq(ShopBoardInfo::getShopId, shopId));
        return R.ok(list);
    }

    @Override
    public void addData(ShopBoardInfo param) {
        if (StringUtils.isEmpty(param.getShopId())) {
            throw new AppException("请选择商铺");
        }
        if (StringUtils.isEmpty(param.getBoardName())) {
            throw new AppException("请输入餐桌名称");
        }
        if (StringUtils.isEmpty(param.getQrCode())) {
            throw new AppException("请生成点餐二维码");
        }
        this.save(param);
    }
}
